home *** CD-ROM | disk | FTP | other *** search
- Path: news.luc.edu!user
- From: VArase@varase.it.luc.edu (Verne Arase)
- Newsgroups: comp.lang.c
- Subject: Re: malloc question
- Date: Mon, 11 Mar 1996 10:02:54 -0600
- Organization: LUMC
- Message-ID: <AD69AACE9668D78B0@mcdiala09.it.luc.edu>
- References: <4htonk$350@news.hklink.net> <4huctt$arv@sparcserver.lrz-muenchen.de> <314318AF.30F@iperbole.bologna.it> <4hvaj4$laj@solutions.solon.com>
- NNTP-Posting-Host: 147.126.240.109
-
- In article <4hvaj4$laj@solutions.solon.com>,
- seebs@solutions.solon.com (Peter Seebach) wrote:
-
- >>Error?!? Why do you think that casting is an error? The standard ANSI
- >>runtime library says:
- >
- >He didn't say it was an error, he said it could *hide* an error.
-
- Well, in the general case it _could_ hide an error.
-
- In this specific case, however, it _never_ hides an error. If malloc is
- used in its standard context, we are simply coercing a slab of memory
- aligned to the most stringent boundaries into a pointer of the desired
- type.
-
- Provided the associated header is included (and the memory model doesn't
- change through some devious, manual manipulation), you are _always_ safe in
- coercing a malloc allocated block of memory into the desired pointer type.
-
- ***** flame on ******
- This is one reason I stopped participating in C conferences; there's always
- some language lawyer who'll tell a novice that a cast is an evil (even if
- it has to do with casting a char * to an unsigned char * for use in a file
- name). What they normally fail to tell you is that any code much beyond the
- sophistication of "Hello World" practically requires casts to produce
- workable code.
-
- IMO, making a char a signed quantity (along with the infamous misplacement
- of the boolean and operator's priority) have made more C programmer's lives
- miserable than any other construct in any other language (that I've
- encountered).
-
- Sure there are constructs that'll get you in trouble. But let us not forget
- that C is the original "gun, bullet, foot" language, and requires care in
- its use and execution.
- ***** flame off *****
-
- ---
- The above are my own opinions, and not those of my employer.
-